package com.chinasofti;

import java.util.Scanner;
//需求，已知用户名和密码，请用程序模拟用户登录，
// 总共提供三次机会，登录之后给出相应的提示
public class lianxi {
    public static void main(String[] args) {
       String name = "admin";
       String pwd = "123456";
       Scanner sc = new Scanner(System.in);
        for (int i = 1; i <=3 ; i++) {
            System.out.println("请输入用户名");
            String n = sc.next();
            System.out.println("请输入密码");
            String p = sc.next();
            if(n.equals(name) && p.equals(pwd) ){
                System.out.println("登录成功");
                break;
            }
            if(i==3){
                System.out.println("今天登录已到达上线");
            }
            else {
                System.out.println("还有"+(3-i)+"次输入机会");
            }

        }

    }
}
